package com.ruoyi.system.media;


/**
 *	分省累计实收金额编码信息
 * @author wuxi_twz
 *
 */
public class ObuProvEd 
{
	/**省份区域编码(1,1,cn),河南为0x41*/
	public byte[] provId = new byte[1];
	
	/**分省累计实收金额(2-4,3,n)，单位：分*/
	public byte[] ProvToll = new byte[3];

	
	public byte[] toBytes()
	{
		byte[] ret = ZTools.sbMerger(
				provId,	ProvToll);
		return ret;
	}
	
	public String toHexStr()
	{
		return ZTools.bin2hex(toBytes());
	}	

	/**
	 *	信息解码
	 * @return
	 */
	public ObuProv decoded()
	{
		ObuProv dd = new ObuProv();
		dd.provId = ZTools.bin2hex(provId);
		dd.ProvToll = ZTools.bin2int(ProvToll);

		return dd;
	}
	
	/**
	 *	信息编码
	 * @param dd
	 * @return
	 */
	public static ObuProvEd encoded(ObuProv dd)
	{
		ObuProvEd ed = new ObuProvEd();
		ed.provId 	= ZTools.hex2bin(1,dd.provId);
		ed.ProvToll = ZTools.int2bin(3,dd.ProvToll);
		
		return ed;
	}
	
	public static ObuProvEd parse(byte[] buff)
	{
		int index=0;
		ObuProvEd ret = new ObuProvEd();
		
		index += ZTools.arrcopy(buff, index, ret.provId);
		index += ZTools.arrcopy(buff, index, ret.ProvToll);
		
		return ret;
	}
	
	public static ObuProvEd parse(String strHex)
	{
		byte[] buff = ZTools.hex2bin(strHex);
		
		return parse(buff);
	}

	public static ObuProvEd sample()
	{
		ObuProvEd ed = new ObuProvEd();
		ed.provId 	= ZTools.hex2bin(1,"41");
		ed.ProvToll = ZTools.int2bin(3,0xFFFFFF);
		
		return ed;
	}
}
